package roborally.program.command;

import roborally.itemsonboard.Robot;
import roborally.supporting.LegalStatus;

/**
 * The general class representing a command that has to be executed/evaluated.
 * 
 * @author Molderez Tom, 2de bach Ingenieurswetenschappen Computerwetenschappen-Elektrotechniek and Reniers Jorn, 2de bach Ingenieurswetenschappen Werktuigkunde-Computerwetenschappen
 * @version 1.0
 *
 */
public abstract class Command {
	
	/**
	 * Creates a new command with no options.
	 */
	protected Command() {
	}
	
	/**
	 * Executes this command.
	 * 
	 * @param robot The robot that should execute the command.
	 * @throws IllegalArgumentException
	 * 		When the robot is not valid.
	 * 		| !canHaveForExecution(robot)
	 */
	public abstract void execute(Robot robot);
	
	/**
	 * Controls if the robot is valid for execution this command.
	 * 
	 * @param robot The robot that must be controlled.
	 * @return False if the robot is null.
	 * 		| if robot == null
	 * 		|	then result == false
	 * @return False if the robot is terminated
	 * 		| if robot.isTerminated()
	 * 		|	then result == false
	 */
	public boolean canHaveForExecution(Robot robot) {
		if(robot == null)
			return false;
		if(robot.isTerminated())
			return false;
		return true;
	}
	
	/**
	 * Returns a String-representation of this command.
	 */
	public abstract String write();
	
	
	/**
	 * Returns a textual presentation of this class.
	 * 
	 * @return The result is the simple name, as in the Java API, of this class.
	 * 		| result == this.getClass().getSimpleName()
	 */
	@Override
	public String toString() {
		return this.getClass().getSimpleName();
	}
	
}
